from rest_framework.generics import ListAPIView, RetrieveAPIView
from .models import CourseCategory, Course
from .serializers import CourseCategoryModelSerializer


class CourseCategoryListAPIView(ListAPIView):
    queryset = CourseCategory.objects.filter(is_show=True, is_deleted=False).order_by("orders")
    serializer_class = CourseCategoryModelSerializer


# from .serializers import CourseModelSerializer
#
#
# class CourseListAPIView(ListAPIView):
#     queryset = Course.objects.filter(is_show=True, is_deleted=False).order_by("order", "-id")
#     serializer_class = CourseModelSerializer


from .serializers import CourseModelSerializer
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import OrderingFilter
from .paginations import CustomPageNumberPagination


class CourseListAPIView(ListAPIView):
    queryset = Course.objects.filter(is_show=True, is_deleted=False).order_by("orders", "-id")
    serializer_class = CourseModelSerializer
    filter_backends = [DjangoFilterBackend, OrderingFilter]
    filterset_fields = ('course_category',)
    ordering_fields = ('id', 'students', 'price')
    pagination_class = CustomPageNumberPagination


from rest_framework.generics import RetrieveAPIView
from .serializers import CourseRetrieveModelSerializer


class CourseRetrieveAPIView(RetrieveAPIView):
    queryset = Course.objects.filter(is_show=True, is_deleted=False).order_by("orders", "-id")
    serializer_class = CourseRetrieveModelSerializer


from .serializers import CourseChapterModelSerializer
from .models import CourseChapter


class CourseChapterListAPIView(ListAPIView):
    queryset = CourseChapter.objects.filter(is_show=True, is_deleted=False).order_by("orders", "id")
    serializer_class = CourseChapterModelSerializer
    filter_backends = [DjangoFilterBackend]
    filterset_fields = ['course']
